package it.enea.xlab.tebes.validation;

import it.enea.xlab.tebes.validation.common.PropertiesUtil;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.interceptor.Interceptors;

import exception.LocalFileNotFoundException;
import exception.SchemaParserException;

import schemavalidator.SchemaMainValidator;
import schemavalidator.SchemaMainValidatorImpl;
import validator.ErrorMessage;

@Stateless
@Interceptors({Profile.class})
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ValidationManagerImpl implements ValidationManagerRemote {

	public ErrorMessage[] validation(String xmlRelPathFileName, String xsdURL) {
		System.out.println("ValidationManagerImpl:qwqw1");
		ErrorMessage emList[] = null;
		
		String validationArtifactsDir = PropertiesUtil.getArtifactsDirProperty();
		
		SchemaMainValidator smv = new SchemaMainValidatorImpl();
		smv.setRootDir("");
		//validationArtifactsDir
		try {
			System.out.println("ValidationManagerImpl:qwqw");
			emList = smv.reportValidation(xmlRelPathFileName, xsdURL);
			
		} catch (LocalFileNotFoundException e) {
			emList = null;
			e.printStackTrace();
		} catch (SchemaParserException e) {
			emList = null;
			e.printStackTrace();
		}
		
		return emList;
	}

	public Long nothing() {
		
		
		System.out.println("qwqw-1");
		return new Long(-1);
	}
	
}
